﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace Wozuji.Logic
{
    public class UserPost
    {
        /// <summary>
        /// 增加用户post
        /// </summary>
        /// <param name="title"></param>
        /// <param name="Context"></param>
        /// <param name="openConfig"></param>
        /// <param name="target"></param>
        /// <param name="setconfig"></param>
        /// <returns></returns>
        public int addPost(String title,String Context,String openConfig,String target,String setconfig)
        {

            Wozuji.Model.UserPost_t up = new Wozuji.Model.UserPost_t();
            up.UserPost_Title = title;
            up.UserPost_Content = Context;
            up.UserPost_Hit = 0;
            up.UserPost_IsTop = false;
            up.UserPost_Time = DateTime.Now;
            up.UserPost_Updatetime = DateTime.Now;
            up.UserPost_tags = target;
            up.UserPost_Replay = 0;
            up.UserPost_UserId = Convert.ToInt32(HttpContext.Current.Session["userid"].ToString());
            up.UserPost_TeamId = 0;
            up.UserPost_setConfig = setconfig;
            up.UserPost_openConfig = openConfig;
            Wozuji.BLL.UserPost_t upbll = new Wozuji.BLL.UserPost_t();            
           return upbll.Add(up);
        }
        /// <summary>
        ///修改用户提交post
        /// </summary>
        /// <param name="nid"></param>
        /// <param name="newContext"></param>
        /// <param name="openConfig"></param>
        /// <param name="target"></param>
        /// <param name="setconfig"></param>
        public void editPost(int nid,String newContext,String openConfig,String target,String setconfig)
        {
             Wozuji.BLL.UserPost_t upbll = new Wozuji.BLL.UserPost_t();       
            Wozuji.Model.UserPost_t up=upbll.GetModel(nid);
            if(!(up==null))
            {
                up.UserPost_Content = newContext;
                up.UserPost_Updatetime = DateTime.Now;
                up.UserPost_openConfig = openConfig;
                up.UserPost_tags = target;
                up.UserPost_setConfig = setconfig;
                upbll.Update(up);
            }
        }
        /// <summary>
        /// 删除post
        /// </summary>
        /// <param name="nid"></param>
        public void delPost(int nid)
        {
            Wozuji.BLL.UserPost_t upbll = new Wozuji.BLL.UserPost_t();
            upbll.Delete(nid);
            
        }
        public DataSet getPage(int pagesize,int page, String where)
        {
            Wozuji.BLL.getPage gp = new BLL.getPage();
            return gp.GetList(pagesize, page, where);
        }
    }
}
